import request from '@/utils/request'

// 查询房产列表
export function listHouse(query) {
  return request({
    url: '/door/house/list',
    method: 'get',
    params: query
  })
}

// 查询房产详细
export function getHouse(id) {
  return request({
    url: '/door/house/' + id,
    method: 'get'
  })
}

// 新增房产
export function addHouse(data) {
  return request({
    url: '/door/house',
    method: 'post',
    data: data
  })
}

// 修改房产
export function updateHouse(data) {
  return request({
    url: '/door/house',
    method: 'put',
    data: data
  })
}

// 删除房产
export function delHouse(id) {
  return request({
    url: '/door/house/' + id,
    method: 'delete'
  })
}

// 导出房产
export function exportHouse(query) {
  return request({
    url: '/door/house/export',
    method: 'get',
    params: query
  })
}

// 下载房产导入模板
export function importTemplate() {
  return request({
    url: '/door/house/importTemplate',
    method: 'get',
    responseType: 'blob'
  })
}

// 导入房产数据
export function importData(file) {
  const formData = new FormData();
  formData.append("file", file);
  return request({
    url: '/door/house/importData',
    method: 'post',
    data: formData,
    headers: {
      'Content-Type': 'multipart/form-data'
    },
    responseType: 'blob' // 添加这个来处理文件流响应
  })
}

